package com.self.campussecondhandmarket.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.self.campussecondhandmarket.entity.domain.Comment;
import com.self.campussecondhandmarket.entity.domain.Orders;
import com.self.campussecondhandmarket.entity.request.comment.Add;
import com.self.campussecondhandmarket.mapper.CommentMapper;
import com.self.campussecondhandmarket.service.CommentService;
import com.self.campussecondhandmarket.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 31465
 * @description 针对表【tb_comment(评论表)】的数据库操作Service实现
 * @createDate 2024-04-13 21:09:43
 */
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment>
		implements CommentService {
	
	@Autowired
	OrdersService ordersService;
	
	@Override
	public void add(Add dto) {
		Orders orders = ordersService.getById(dto.getOrdersId());
		Comment vo = new Comment();
		vo.setStar(dto.getStar());
		vo.setGoodsId(orders.getGoodsId());
		vo.setUserId(orders.getUserId());
		vo.setCommentContent(dto.getContent());
		vo.setOrdersId(orders.getId());
		this.baseMapper.insert(vo);
	}
}




